|
|
|
|
|
|
|
Note When a form is loaded, any Data controls on the form will be initialized with the settings assigned at design time. To modify them before the Data control is initialized, you should place the code that modifies the control in the form's Initialize event routine. |
|
|
|
|
|
|
|
|
|
You can also set the properties of the bound controls at runtime. The DataSource of the bound control can be changed to access a different Data control on the form. You can also change the setting of the DataField property to have the control display the contents of a different field in the recordset. |
|
|
|
|
|
|
|
|
You can use several key events to manipulate the way the Data control performs: |
|
|
|
 |
|
|
|
|
WillChangeRecord, WillChangeRecordset, and WillChangeFieldprocess any data before the record is updated. |
|
|
|
 |
|
|
|
|
Error is triggered for any data-access error. |
|
|
|
 |
|
|
|
|
MoveComplete is used to perform calculations based on data in the current record or to change the form in response to data in the current record. |
|
|
|
|
|
|
|
|
Although most of the Data control's actions are handled automatically, these events can help you add enhanced capabilities to your application. |
|
|
|
|
|
|
|
|
When you need to add validation processing to your application, you would use the WillChangeField event, which is triggered just before a value of one or more Field objects in the Recordset is changed. However, if a method such as Update, Delete, or AddNew is executed, you would use the WillChangeRecord event to perform the validation for the entire record. This event occurs when users process a navigation button on the Data control or when the form containing the Data control is unloaded. |
|
|
|
|
|
|
|
|
The WillChangeField event is triggered whenever a field in the current record is changed and an Update or Move method is executed. The parameters used by the WillChangeField event are |
|
|
|
 |
|
|
|
|
cFieldsContains the number of field objects that are currently in the Fields Collection |
|
|
|
 |
|
|
|
|
FieldsThe collection that contains the Field objects with the pending changes |
|
|
|
 |
|
|
|
|
adStatusContains the status of the change event |
|
|
|
|
|
|
|
|
The values for the adStatus parameter let you specify whether to allow or prevent the change of the field's data. When you are using a method that affects the entire record, the |
|
|
|
|
|